Destructuring
Destructuring is a better way to assign local variables from expressions that return a table.
Array destructuring
Assuming we have this table:
plutolocal t = { 3, 6, 9 }
This is how we would assign each value to variables called a, b, and c using the Lua and Pluto ways:
Lua wayplutolocal a, b, c = table.unpack(t)
Pluto wayplutolocal [a, b, c] = t
Table destructuring
Assuming we have this table:
plutolocal t = {name = "John",age = 42}
This is how we would assign each field to a variable of the same name using the Lua and Pluto ways:
Lua wayplutolocal name = t.namelocal age = t.age
Pluto wayplutolocal { name, age } = t
Different variable name
Assuming we have the same table as above, this is how we'd assign the name and age fields to n and a variables, respectively, using the Lua and Pluto ways:
Lua wayplutolocal n = t.namelocal a = t.age
Pluto wayplutolocal { n = name, a = age } = t
Standard Library
Table destructuring can be used to require multiple standard library modules at once using the '*' module:
plutolocal { base64, json } = require "*"